﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Adapter.SISCONVE.Helper;
using Adapter.SISCONVE.Pages;
using ArtOfTest.WebAii.Controls.HtmlControls;
using ArtOfTest.WebAii.Core;

namespace AdapterSISCONVE.Pages
{
    public class ReportsPage : BasePage
    {
        private const string btnReports = "xpath=//*[@id='ctl00_btnReportes_btnGISButton']";
        private const string btnPerformance = "xpath=//*[@id='ctl00_btnRendimientoCombustible_btnGISButton']";
        private const string btnagregarTodos = "xpath=//*[@id='ctl00_ContentPlaceHolder2_btnIncluirTodos_btnGISButton']";
        private const string btnGenerarReporte = "xpath=//*[@id='ctl00_ContentPlaceHolder2_btnGenerar_btnGISButton']";
        private const string btnExcel = "xpath=//*[@id='ctl00_ContentPlaceHolder1_btnExportarExcel']";
        private const string btnLinkDescarga = "xpath=//*[@id='tdDescargar']/a";
        private const string selectDivisionId = "ctl00$ContentPlaceHolder1$cmbSelDivision";                                  
        private const string btnReportAllVehicles = "xpath=//*[@id='ctl00_btnReporteMoviles_btnGISButton']";
        private const string btnFilter = "xpath=//*[@id='ctl00_ContentPlaceHolder1_btnFiltrar_btnGISButton']";

        public ReportsPage(Manager manager)
            : base(manager)
        {
            
        }

        public ReportsPage()
        {
        }

        public void ClickButtonReports()
        {
            Click(btnReports);
        }

        public void ClickButtonPerformance()
        {
            Click(btnPerformance);
        }

        public void ClickButtonAgregarTodosVehiculos()
        {
            Click(btnagregarTodos);
        }
        public void ClickButtonGenerarReporte()
        {
            Click(btnGenerarReporte);
        }

        public void ClickButtonExcel()
        {
            Click(btnExcel);
        }

        public void ClickLinkDescarga()
        {
            Click(btnLinkDescarga);
        }

        public void ClickButtonReportAllVehicles()
        {
            Click(btnReportAllVehicles);
        }

        public void ClickButtonFilter()
        {
            Click(btnFilter);
        }

        public void SelectDivisionByName(string divisionName)
        {
            foreach (HtmlOption option in SelectDivision.Options)
            {
                if (option.Text.IndexOf(divisionName, 0) != -1)
                {
                    string text = option.Text;
                    SelectDivision.SelectByText(text, true);
                    break;
                }
            }
        }

        private HtmlSelect SelectDivision
        {
            get
            {
                return GetBrowser().Find.ById<HtmlSelect>(selectDivisionId);
            }
        }

    }
}
